// pages/after_sale_detail/after_sale_detail.js
var common = require("../../common/common.js").common;

Page({
    /**
   * 页面的初始数据
   */
    data: {
        rp_name: "",
        color_header: "",
        color_main: "",
        color_minor: "",
        details: "",
        id: ""
    },
    /**
   * 生命周期函数--监听页面加载
   */
    onLoad: function(options) {
        this.setData({
            id: options.id
        });
        this.getBase();
        this.getData();
    },
    /**
   * 生命周期函数--监听页面初次渲染完成
   */
    onReady: function() {},
    /**
   * 生命周期函数--监听页面显示
   */
    onShow: function() {},
    /**
   * 生命周期函数--监听页面隐藏
   */
    onHide: function() {},
    /**
   * 生命周期函数--监听页面卸载
   */
    onUnload: function() {},
    /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
    onPullDownRefresh: function() {},
    /**
   * 页面上拉触底事件的处理函数
   */
    onReachBottom: function() {},
    /**
   * 用户点击右上角分享
   */
    onShareAppMessage: function() {},
    //获取基础信息
    getBase: function() {
        var that = this;
        common.request({
            endpoint: "set/app_base",
            method: "get",
            data: {},
            success: res => {
                wx.setNavigationBarColor({
                    frontColor: "#ffffff",
                    backgroundColor: res.extra.color_main
                });
                that.setData({
                    color_main: res.extra.color_main,
                    color_minor: res.extra.color_minor,
                    rp_name: res.extra.rp_name,
                    little_title: res.extra.title
                });
            }
        });
    },
    //获取数据
    getData: function() {
        let that = this;
        let id = that.data.id;
        common.request({
            endpoint: "My/myinfo/order_detail_after",
            method: "post",
            data: {
                id: id
            },
            success: res => {
                that.setData({
                    details: res.extra
                });
            }
        });
    },
    //复制
    order_copy: function(e) {
        var copy = e.currentTarget.dataset.copy;
        wx.setClipboardData({
            data: copy,
            success: function(res) {
                wx.showToast({
                    title: "复制成功",
                    icon: "succes",
                    duration: 1e3,
                    mask: true
                });
            }
        });
    },
    //拨打电话
    index_call: function(e) {
        var phone = e.currentTarget.dataset.phone;
        wx.makePhoneCall({
            phoneNumber: phone
        });
    }
});